<%-- 
    Document   : InsertKamusGiziAdmin
    Created on : Nov 25, 2013, 8:32:18 AM
    Author     : Renia
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>InsertAdmin</title>
    </head>
    <body>
        <%
            Connection con = null;
            String idPangan = request.getParameter("idPanganInput");
            String namaPangan = request.getParameter("namaPanganInput");
            String beratPangan = request.getParameter("beratPanganInput");
            String urtPangan = request.getParameter("urtPanganInput");
            String kaloriPangan = request.getParameter("kaloriPanganInput");
            Double kaloriD = Double.valueOf(kaloriPangan);
            String karboPangan = request.getParameter("karboPanganInput");
            Double karboD = Double.valueOf(karboPangan);
            String proteinPangan = request.getParameter("proteinPanganInput");
            Double proteinD = Double.valueOf(proteinPangan);
            String lemakPangan = request.getParameter("lemakPanganInput");
            Double lemakD = Double.valueOf(lemakPangan);
            String idKategoriPangan = request.getParameter("idKategoriPanganInput");
            String queryText = ("INSERT INTO PANGAN (idPangan, namaPangan, beratPangan, "
                    + "urtPangan, kaloriPangan, karboPangan, proteinPangan, lemakPangan, idKategori) "
                    + "VALUES ('" + idPangan + "' , '" + namaPangan + "' , '" + beratPangan + "' , '" + urtPangan + "' , '"
                    + kaloriD + "' , '" + karboD + "' , '" + proteinD + "' , '" + lemakD + "' , '" + idKategoriPangan + "')");
            try {
                Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
               // con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "MHS115314078", "mhs115314078");
                 con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "HR", "renia");
                Statement stat = con.createStatement();
                ResultSet rst = stat.executeQuery(queryText);
                rst.close();
                stat.close();
                con.close();
            } catch (Exception e) {
                out.println("Error.." + e);
            }
             response.sendRedirect("KamusGiziAdministrator.jsp");
        %>
    </body>
</html>
